package cn.fintecher.pangolin.entity.mysql;

import cn.fintecher.pangolin.common.enums.ApprovalResult;
import cn.fintecher.pangolin.common.enums.ApprovalStatus;
import cn.fintecher.pangolin.common.enums.BaseSelect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;
import java.util.Objects;
import java.util.Set;

/**
 * @Author wangxiangdong
 * @Description 流程实例节点
 * @Date 2019/9/26 14:30
 **/
@Data
@Entity
@Table(name = "process_flow_node")
public class ProcessFlowNode extends BaseEntity{

    @ApiModelProperty("审批节点值")
    private Integer nodeValue;

    @ApiModelProperty("审批状态")
    @Enumerated(EnumType.STRING)
    private ApprovalStatus approvalStatus = ApprovalStatus.WAIT_APPROVAL;

    @ApiModelProperty("审批结果")
    @Enumerated(EnumType.STRING)
    private ApprovalResult approvedResult;

    @ApiModelProperty(notes = "审批意见")
    private String remark;

    @ApiModelProperty(notes = "审批时间")
    private Date approvalTime;

    @ApiModelProperty(notes = "当前审批节点是否可见")
    @Enumerated(EnumType.STRING)
    private BaseSelect isShow = BaseSelect.NO;

    @ApiModelProperty(notes = "是否为最后节点")
    @Enumerated(EnumType.STRING)
    private BaseSelect isEnd = BaseSelect.NO;

    @ApiModelProperty(value = "审批人员")
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "approve_id")
    private Set<ProcessApprover> processApprovers ;

    @ApiModelProperty(value = "申请信息")
    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "flow_config_id")
    private ProcessApplication processApplication;

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), nodeValue, approvalStatus, approvedResult, remark, approvalTime, isShow, isEnd, processApplication);
    }



}
